package bTree.LeetCode;

public class 左叶子之和 {
    int sum = 0;

    public int sumOfLeftLeaves(TreeNode root) {
        loop(root);
        return sum;
    }

    private void loop(TreeNode root) {
        if (root == null) {
            return;
        }
        if (root.left != null && root.left.left == null && root.left.right == null) {
            sum += root.left.val;
        }
        loop(root.left);
        loop(root.right);
    }
}